from django.db import models

class Logs(models.Model):
    """
        This model stores RAW results from every operation on 
        MetaSploit Framework or any other external processess
        run through pexpect module
    """
    LOGTYPES = (
        ('S', 'Scanner log'),
        ('E', 'Exploitation log'),
    )
    class Meta:
        db_table = "logs"
    eventType = models.CharField(maxlength=1,choices=LOGTYPES)
    eventText = models.TextField()
    eventTime = models.DateTimeField(auto_now_add=True)
    def __str__(self):
        return "[%s %s] %s" % (self.eventType, self.eventTime, self.eventText)

class Session(models.Model):
    class Meta:
        db_table = "sessions"
    lhost = models.IPAddressField()
    lport = models.PositiveIntegerField()
    rhost = models.IPAddressField()
    rport = models.PositiveIntegerField()
    created = models.DateTimeField(auto_now_add=True)
    
    #def __str__(self):
        #return "%s:%d -> %s:%d" % (self.lhost, self.lport, self.rhost, self.rport)
        #return rhost
    